fix: harden ImageMagick policy and install rsvg-convert (OC10-164) - #309
Open
oc-tmueller wants to merge 1 commit into
Open
fix: harden ImageMagick policy and install rsvg-convert (OC10-164)#309oc-tmueller wants to merge 1 commit into
oc-tmueller wants to merge 1 commit into
Conversation
Neither owncloud-docker/ubuntu, php, base nor server ship any ImageMagick
policy.xml or MAGICK_CONFIGURE_PATH override - the product runs on whatever
the OS imagemagick-6-common package defaults to, which denies neither the
MSL/MVG/MSVG script coders nor the EPHEMERAL/TEXT/SHOW/WIN/PLT/LABEL/
CAPTION/PANGO coders. Confirmed against the real published owncloud/server
:11.0.0 and :10.16.4 images: readImage("msl:...") and the SVG
<image xlink:href="MSL:...">/MVG "image" primitive vectors that
owncloud/core's OC10-164 fix addresses in application code are not blocked
by ImageMagick's own policy at all.
Deny MSL, MVG, MSVG, EPHEMERAL, TEXT, SHOW, WIN, PLT, LABEL, CAPTION and
PANGO coders, plus the URL/HTTPS/HTTP/FTP delegates, matching the ticket's
Item A recommendation. Deliberately does not touch the PS/PDF/EPS/XPS
coders or add a blanket delegate/coder deny-all: ownCloud's PDF and
Postscript previews decode through the Ghostscript delegate, and a
deny-all would break them - upstream ImageMagick's own hardening advice
warns against exactly that.
Also install librsvg2-bin (missing in both real images - only the .so from
librsvg2-common was present, not the rsvg-convert binary). ImageMagick's
delegates.xml routes SVG decoding to rsvg-convert; without the binary on
PATH it silently falls through to ImageMagick's own internal SVG/MSVG
coder, the exact vulnerable path. This is a second, independent layer: it
protects any future code path that reads SVG content through Imagick,
not just the one owncloud/core patches.
Verified by building v24.04 locally and replicating the v22.04 package set
on a bare ubuntu:22.04 container (v22.04's own Dockerfile needs a private
Freexian mirror secret this environment doesn't have): msl:, the SVG
xlink:href="MSL:..." PoC payload, and an MVG "image" primitive referencing
msl: are all blocked by policy on both; a real PDF and a legitimate SVG
both still render correctly afterward.
Signed-off-by: Thomas Müller <323649642+oc-tmueller@users.noreply.github.com>
|
Cross-linking the code-side thread: pinning the Imagick coder instead of letting ImageMagick sniff Nothing needed in this PR for that — noting it here so the image-side and code-side threads are |
phil-davis
approved these changes
Sep 11, 2026
phil-davis
left a comment
Contributor
There was a problem hiding this comment.
LGTM - tightens what ImageMagick is allowed to process.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to owncloud/core#41827 / #41828 (OC10-164, arbitrary file read/write via ImageMagick's MSL coder). That fix closes the code-level gap in
Bitmap::getResizedPreview(); this PR closes the corresponding gap in the Docker image, matching the ticket's "Item A" recommendation.Checked all four repos in the image chain (
owncloud-docker/ubuntu→php→base→server, both v22.04 and v24.04) - none ship an ImageMagickpolicy.xmloverride orMAGICK_CONFIGURE_PATH. The product runs on whatever the OSimagemagick-6-commonpackage defaults to.Confirmed against the real published images (
docker pull owncloud/server:11.0.0/:10.16.4, not a reconstruction):MSL/MVG/MSVGcoders.Imagick->readImage("msl:...")executes unrestricted in both.librsvg2-common(the shared library) is installed butlibrsvg2-bin(which provides thersvg-convertbinary) is not. ImageMagick'sdelegates.xmlroutesdecode="svg"torsvg-convert; without the binary, it silently falls through to ImageMagick's own internal SVG/MSVG coder - the exact vulnerable path.Changes
v22.04/overlay/etc/ImageMagick-6/policy.xmlandv24.04/.../policy.xml(new): deny theMSL,MVG,MSVG,EPHEMERAL,TEXT,SHOW,WIN,PLT,LABEL,CAPTION,PANGOcoders and theURL/HTTPS/HTTP/FTPdelegates. Deliberately does not touchPS/PDF/EPS/XPSor add a blanket delegate/coder deny-all - ownCloud's PDF and Postscript previews decode through the Ghostscript delegate, and upstream ImageMagick's own hardening advice warns that a deny-all breaks exactly that.Dockerfile.multiarch: addlibrsvg2-binnext to the existinglibrsvg2-common.Side finding, not fixed here: the current
10.16.4image's own OS-default policy already denies thePDFcoder outright (confirmed:Imagick->readImage()on a real PDF throws "not allowed by the security policy `PDF'" in the actual running container) - so PDF preview generation is currently broken on that line already, independent of this change.11.0.0's policy doesn't have that same denial. My newpolicy.xmldoes not deny PDF/PS/EPS/XPS, so shipping it has the side effect of fixing that pre-existing 10.16 defect rather than perpetuating it. Flagging in case an admin has already reported "PDF previews don't work" against 10.16 - this PR is likely the fix for that too, though I didn't chase why the two lines' packaged policies differ.Test plan
Built
v24.04/Dockerfile.multiarchlocally and verified in the built image:php --versionreports PHP 8.3rsvg-convertpresent on PATHImagick->readImage("msl:...")blocked: "not allowed by the security policy `MSL'"<svg><image xlink:href="MSL:...">) renders but does not execute the MSL script (no file written)imageprimitive referencingmsl:is blockedrsvg-convertdelegate)v22.04/Dockerfile.multiarchneeds a private Freexian mirror secret to build that isn't available in my environment, so I replicated its OS-level package set (imagemagick-6-common,librsvg2-common,librsvg2-bin,ghostscript- none of which come from the Freexian mirror) on a bareubuntu:22.04container with the samepolicy.xmloverlaid, and reran the identical test suite above - same results, including the PDF-previously-broken-now-fixed side effect.